{include file="public/head" /}
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
          <a><cite>后台管理</cite></a>
          <a><cite>管理员管理</cite></a>
          <a><cite>收银台</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so layui-form-pane"  action="{:url('admin/Cashier/cashierList')}" method="get">
          <div class="layui-input-inline" style="text-align: left;">
              <select name="community_id">
                  <option selected="true" value="">所属小区</option>
                  {foreach $communitylist as $com}
                    <option value="{$com.community_id}" {if isset($community_id)}{if $community_id == $com.community_id}selected{/if}{/if}>{$com.community_name}</option>
                  {/foreach}
              </select>
          </div>
          <input class="layui-input" placeholder="业务类型" name="business_type" value="{if isset($business_type)}{$business_type}{/if}">
          <input class="layui-input" placeholder="付款单位" name="company" value="{if isset($company)}{$company}{/if}">
          <input class="layui-input" placeholder="联系电话" name="phone" value="{if isset($phone)}{$phone}{/if}">
          <div class="layui-input-inline" style="text-align: left;">
              <select name="paytype">
                  <option selected="true" value="">支付方式</option>
                  <option value="支付宝">支付宝</option>
                  {foreach $paytypes as $pay}
                    <option value="{$pay.name}" {if isset($paytype)}{if $paytype == $pay.name}selected{/if}{/if}>{$pay.name}</option>
                  {/foreach}
              </select>
          </div>
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon"></i>查询</button>
        </form>
      </div>
      <xblock>
          <button class="layui-btn" onclick="x_admin_show('添加物业','{:url('cashierAdd')}',680,600)"><i class="layui-icon"></i>添加收银</button>
          <button class="layui-btn layui-btn-danger" onclick="cashierDump()"><i class="layui-icon"></i>批量导出</button>
          
          <button class="layui-btn layui-btn-danger" onclick="invoice()"><i class="layui-icon"></i>电子发票</button>
        <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
             <th style="text-align: center; font-size: 16px;">
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th style="font-size: 16px;text-align:center;">小区名称</th>
            <th style="font-size: 16px;text-align:center;">业务类型</th>
            <th style="font-size: 16px;text-align:center;">付款单位</th>
            <th style="font-size: 16px;text-align:center;">联系电话</th>
            <th style="font-size: 16px;text-align:center;">付款金额</th>
            <th style="font-size: 16px;text-align:center;">状态</th>
            <th style="font-size: 16px;text-align:center;">支付方式</th>
            <th style="font-size: 16px;text-align:center;">付款时间</th>
            <th style="font-size: 16px;text-align:center;">操作</th>
        </thead>
        <tbody>
            {foreach $cashier as $cas}
              <tr>
                <td style="text-align: center;">
                  <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$cas.id}'><i class="layui-icon">&#xe605;</i></div>
                </td>
                <td style="text-align: center;">{$cas.community_id}</td>
                <td style="text-align: center;">{$cas.business_type}</td>
                <td style="text-align: center;">{$cas.company}</td>
                <td style="text-align: center;">{$cas.phone}</td>
                <td style="text-align: center;">{$cas.money}</td>
                <td style="text-align: center;">
                    {if $cas.status=="1"}已付款{/if}
                    {if $cas.status=="2"}未付款{/if}
                </td>
                <td style="text-align: center;">{$cas.paytype}</td>
                <td style="text-align: center;">{$cas.time}</td>
                <td class="td-manage" style="text-align: center;">
                    <a title="删除" onclick="cashierDel('{$cas.id}', '{$cas.id}')" href="javascript:;"  id="{$cas.id}" >
                    <i class="layui-icon">&#xe640;</i>
                </a>
                </td>
              </tr>
            {/foreach}
        </tbody>
      </table>
      <div class="page">
          <div>
            {$cashierlist->render()}
          </div>
      </div>

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;

        
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

      //删除
      function cashierDel(id, doc){
        if(confirm('确定要删除吗?')) 
        { 
          var url = "{:url('cashierDel')}?id=" + id
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 

      //批量导出
      function cashierDump(){
        var url = "{:url('admin/Cashier/cashierExportExcel')}"
        layer.open({
          type: 2,
          title: '批量导出账单',
          shadeClose: true,
          shade: 0.8,
          area: ['80%', '95%'],
          content: url //iframe的url
        }); 
      }
      //批量开票
      function invoice(){
        if(confirm('是否确定开票?')){
          var datas = $('#table tbody td .layui-form-checked')
          var ids = []
          datas.each(function(index, element){
            var id = $(this).data('id')
            ids.push(id)
          })

          var str = ids.join(',');
          var count = ids.length
          var url = "{:url('invoice')}?id=" + str
          layer.open({
            type: 2,
            title: '批量开票',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '95%'],
            content: url //iframe的url
          }); 
        }
        
        
      }
    </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>